package qz_rpt

import java.text.SimpleDateFormat

/**
 * 一次合格率不良按产品分布
 * @Author Ivan
 * @Date 2019/4/1
 */
class OncePassYieldByPartController {

    def commonSqlService
    def dynamicQueryService

    def index(Integer max) {
        def cellList = org.kdx.DataUtils.getCellList()
        def pageSizeList = org.kdx.DataUtils.getPageSizeList()

        [totalCount: 5, pageSize: 20, pageCurrent: 1, orderField: 'id', orderDirection: 'asc', pageSizeList: pageSizeList, cellList: cellList]
    }

    def oncePassYieldByPart(){
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = ((pageCurrent - 1) * pageSize) + 1
        params.endno = pageCurrent * pageSize
        def oncePassYieldByPart=[]
        def oncePassYieldByPartTen=[]
        def pageSizeList = [10,20,50,100]
        def totalCount =0
        def tableHeadList = []
        SimpleDateFormat sdf = new SimpleDateFormat('yyyy-MM-dd')
        def startTime = params.startTime ? sdf.parse(params.startTime) : sdf.parse(sdf.format(new Date().clearTime()))
        def endTime = params.endTime ? sdf.parse(params.endTime) : sdf.parse(sdf.format(new Date()))
        params.startTime = sdf.format(startTime)
        params.endTime = sdf.format(endTime)
//        def customerLotIdList = commonSqlService.customerLotIdList(params)
        params.SYS_QUERY_NAME = 'checkStepList'
        def checkStepList = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'partDirect'
        def partDirect = dynamicQueryService.queryForList(params)

        if(params.EXPORT_CONTENT_NAME=='Excel'){
            params.SYS_QUERY_NAME = 'oncePassYieldByPart'
            oncePassYieldByPart = dynamicQueryService.queryForList(params)

            params.SYS_QUERY_NAME = 'oncePassYieldByPartTen'
            oncePassYieldByPartTen = dynamicQueryService.queryForList(params)

            if (oncePassYieldByPart.size() > 0) {
                tableHeadList = oncePassYieldByPart[0].keySet()
            }

        }



        [pageSize  : pageSize, pageSizeList: pageSizeList, startno: params.startno ?: '', endno: params.endno ?: '',partDirect:partDirect,
         totalCount: totalCount, tableHeadList: tableHeadList,customerLotId:params.customerLotId?:'',
//         customerLotIdList:customerLotIdList,
         group4: params.group4 ?: '', group3: params.group3 ?: '',defectType:params.defectType?:'',checkStep:params.checkStep?:'',
         startTime:params.startTime?:'',endTime:params.endTime?:'',customerDirect:params.customerDirect?:'',
         oncePassYieldByPart:oncePassYieldByPart,checkStepList:checkStepList,oncePassYieldByPartTen:oncePassYieldByPartTen]

    }
}
